export const ListMixin = {
	data() {
		return {
			queryParam: {}, //传入参数
			/* 分页参数 */
			ipagination:{
				page: 0, //当前页
				size: 10,//每页多少条
				total:0,//总条数
			},
			/* 分页参数 */
			dataSource:[],//数据源
			loadStatus:'loadmore',//加载更多状态
		}
	},
	methods: {
		//上拉加载更多(待验证)
		reachBottom(){
			this.loadStatus = 'loading'
			let totalPage = parseInt(this.ipagination.total/this.ipagination.size)
			if(this.ipagination.page===totalPage){
				this.loadStatus = "nomore"
			}else{
				++this.ipagination.page
				this.loadData()
			}
		},
		//加载数据
		loadData() {
			let that = this
			let params =Object.assign(that.queryParam,{page:that.ipagination.page,
			size:that.ipagination.size})
			uni.$u.http.get(that.urlapi.list, {params:params}).then(res => {
				that.ipagination.total= res.totalElements
				that.dataSource = that.dataSource.concat(res.content)
				if(that.dataSource.length===res.totalElements){
					that.loadStatus = "nomore"
				}else{
					that.loadStatus = "loadmore"
				}
				
			})
		}
	}
}
